package com.gemme.gemme.view;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gemme.gemme.R;

public class ProductTuijianSIngleView extends RelativeLayout {
    private Context context;
    public ProductTuijianSIngleView(Context context) {
        this(context,null);
    }

    public ProductTuijianSIngleView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ProductTuijianSIngleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    ImageView iv_picture;
    TextView tv_name;
    TextView tv_desc;
    TextView tv_price;
    TextView tv_price_two;

    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.product_tuijian_single,this);
        iv_picture = findViewById(R.id.iv_picture);
        tv_name = findViewById(R.id.tv_name);
        tv_desc = findViewById(R.id.tv_desc);
        tv_price = findViewById(R.id.tv_price);
        tv_price_two = findViewById(R.id.tv_price_two);
    }

    public void setData(TuijianBean.DataBean.RecordsBean recordsBean) {
        try {
//            iv_picture.setText(recordsBean.get);
            tv_name.setText(recordsBean.getProductDesc());
            tv_desc.setText(recordsBean.getProductName());
            Glide.with(context).load(recordsBean.getAbbreviationPic()).into(iv_picture);
            tv_price_two.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
            tv_price_two.setText("￥"+new Double(recordsBean.getProductPrice()).intValue()+"");
            tv_price.setText("￥"+recordsBean.getPrice());
        }catch (Exception e){

        }
    }
}
